import useBaseQuery from "@/hooks/useBaseQuery";

let baseUrl = process.env.EXPO_PUBLIC_API_URL + '/houseWeb/'
// let baseUrl = 'http://192.168.10.122:8080/' + '/houseWeb/'
import {createApi, fetchBaseQuery} from "@reduxjs/toolkit/query/react";

export const aiFeedingApi = createApi({
    reducerPath: 'aiFeedingApi',
    baseQuery: useBaseQuery('mm'),
    tagTypes: ['itemList','parentList','libraryList','getDocParts','libraryList','product_usage','getMaxFiles','labelList'],
    endpoints(build) {
        return {
            // http://192.168.200.122:3200/jeecgboot/mm/mmVpGroup/add
            // addGroup: build.mutation({
            //     query(data) {
            //         return {
            //             url: 'mmVpGroup/add',
            //             method: "post",
            //             body: data,
            //             openErrMessage: true
            //         }
            //     },
            //     invalidatesTags: ['itemList'],
            //     // transformResponse(baseQueryReturnValue, meta, arg) {
            //     //     return baseQueryReturnValue.data;
            //     // },
            //     // keepUnusedDataFor: 60, // 设置数据缓存的时间，单位秒 默认60s
            // }),
            profitModelInfo: build.mutation({
                query(data) {
                    return {
                        url: 'mmVpGroup/profitModelInfo?id='+data.id,
                        method: "post",
                        openErrMessage: true
                    }
                }
            }),
            // http://192.168.200.122:3200/jeecgboot/mm/mmVpGroup/profitModel
            profitModel: build.mutation({
                query(data) {
                    return {
                        url: 'mmVpGroup/profitModel',
                        method: "post",
                        body: data,
                        openErrMessage: true
                    }
                }
            }),
            // http://192.168.200.122:3200/jeecgboot/mm/mmVpGroup/analysisCustomerStr
            analysisCustomerStr: build.mutation({
                query(data) {
                    return {
                        url: 'mmVpGroup/analysisCustomerStr',
                        method: "post",
                        body: data,
                        openErrMessage: true
                    }
                }
            }),
            // http://192.168.200.122:3200/jeecgboot/mm/mmVpGroup/analysis
            analysis: build.mutation({
                query(data) {
                    return {
                        url: 'mmVpGroup/analysis',
                        method: "post",
                        body: data,
                        openErrMessage: true
                    }
                }
            }),

            // http://192.168.200.122:3200/jeecgboot/mm/mmVpLibrary/list?fileName=&fileSourceType=1&thirdPartyId=1867489691664695298&pageNo=1&pageSize=20&_t=1737883195067
            libraryList: build.query({
                query(data) {
                    return {
                        url: 'mmVpLibrary/list',
                        method: "get",
                        params: data,
                        openErrMessage: true
                    }
                },
                providesTags: ['libraryList'],
            }),
            // http://192.168.200.122:3200/jeecgboot/mm/mmVpLabel/list?name=&pageSize=1000&_t=1737908143086
            labelList: build.query({
                query(data) {
                    return {
                        url: 'mmVpLabel/list',
                        method: "get",
                        params: data,
                        openErrMessage: true
                    }
                },
                providesTags: ['labelList'],
            }),
            addLabel: build.mutation({
                query(data) {
                    return {
                        url: 'mmVpLabel/add',
                        method: "post",
                        body: data,
                        openErrMessage: true
                    }
                },
                invalidatesTags: ['labelList'],
            }),
            editLabel: build.mutation({
                query(data) {
                    return {
                        url: 'mmVpLabel/edit',
                        method: "post",
                        body: data,
                        openErrMessage: true
                    }
                },
                invalidatesTags: ['labelList'],
            }),
            deleteLabel: build.mutation({
                query(data) {
                    return {
                        url: 'mmVpLabel/deleteBatch',
                        // url: 'mmVpLabel/deleteBatch?ids='+data.ids,
                        method: "post",
                        body: data,
                        openErrMessage: true
                    }
                },
                invalidatesTags: ['labelList'],
            }),
            // http://192.168.200.122:3200/jeecgboot/mm/mmVpLibrary/batchSetLabel
            batchSetLabel: build.mutation({
                query(data) {
                    return {
                        url: 'mmVpLibrary/batchSetLabel',
                        method: "post",
                        body: data,
                        openErrMessage: true
                    }
                },
                invalidatesTags: ['libraryList'],
            }),
            // http://192.168.200.122:3200/jeecgboot/mm/mmVpLibrary/delLabel
            delLabel: build.mutation({
                query(data) {
                    return {
                        url: 'mmVpLibrary/delLabel',
                        method: "post",
                        body: data,
                        openErrMessage: true
                    }
                },
                invalidatesTags: ['libraryList'],
            }),
            // http://192.168.200.122:3200/jeecgboot/mm/mmVpLibrary/delete?id=1883700780735696898
            deleteFile: build.mutation({
                query(data) {
                    return {
                        url: 'mmVpLibrary/delete?id='+data.id,
                        method: "delete",
                        openErrMessage: true
                    }
                },
                invalidatesTags: ['libraryList'],
            }),
            // http://192.168.200.122:3200/jeecgboot/mm/mmVpLibrary/getDocParts
            getDocParts: build.mutation({
                query(data) {
                    return {
                        url: 'mmVpLibrary/getDocParts',
                        method: "post",
                        body: data,
                        openErrMessage: true
                    }
                },
                providesTags: ['getDocParts'],
            }),
            // http://192.168.200.122:3200/jeecgboot/mm/mmVpLibrary/ai
            libraryAi: build.mutation({
                query(data) {
                    return {
                        url: 'mmVpLibrary/ai',
                        method: "post",
                        body: data,
                        openErrMessage: true
                    }
                },
                invalidatesTags: ['getDocParts'],
            }),
            // http://192.168.200.122:3200/jeecgboot/mm/mmVpLibrary/keyword
            saveKeyword: build.mutation({
                query(data) {
                    return {
                        url: 'mmVpLibrary/keyword',
                        method: "post",
                        body: data,
                        openErrMessage: true
                    }
                },
            }),
            // http://192.168.200.122:3200/jeecgboot/mm/mmVpLibrary/add
            addLibrary: build.mutation({
                query(data) {
                    return {
                        url: 'mmVpLibrary/add',
                        method: "post",
                        body: data,
                        openErrMessage: true
                    }
                },
                invalidatesTags: ['libraryList'],
            }),
            // http://192.168.200.122:3200/jeecgboot/mm/mmVpLibrary/getMaxFiles?_t=1738885117906
            getMaxFiles: build.query({
                query(data) {
                    return {
                        url: 'mmVpLibrary/getMaxFiles',
                        method: "get",
                        params: data,
                        openErrMessage: true
                    }
                },
                providesTags: ['getMaxFiles'],
            }),

            // http://192.168.200.122:3200/jeecgboot/mm/mmProductUsage/product_usage?productUsageType=SCORE&_t=1738886538028
            getProductUsage: build.query({
                query(data) {
                    return {
                        url: 'mmProductUsage/product_usage',
                        method: "get",
                        params: data,
                        openErrMessage: true
                    }
                },
                providesTags: ['product_usage'],
            }),
            // mm/vpLibraryExpansion/expansion
            expansion: build.mutation({
                query(data) {
                    return {
                        url: 'vpLibraryExpansion/expansion',
                        method: "post",
                        body: data,
                        openErrMessage: true
                    }
                },
                invalidatesTags: ['product_usage','getMaxFiles'],
            }),
        }
    }
});

export const {
    // useAddGroupMutation,
    useProfitModelInfoMutation,
    useProfitModelMutation,
    useAnalysisCustomerStrMutation,
    useAnalysisMutation,
    useLibraryListQuery,
    useLabelListQuery,
    useAddLabelMutation,
    useEditLabelMutation,
    useDeleteLabelMutation,
    useBatchSetLabelMutation,
    useDelLabelMutation,
    useDeleteFileMutation,
    useGetDocPartsMutation,
    useLibraryAiMutation,
    useSaveKeywordMutation,
    useAddLibraryMutation,
    useGetMaxFilesQuery,
    useGetProductUsageQuery,
    useExpansionMutation,
} = aiFeedingApi;
